<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/resetMui/reset.css" />
		<link rel="stylesheet" type="text/css" href="css/main/main.css" />
		<link rel="stylesheet" type="text/css" href="css/main/warnList.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left">工作台</a>
			<h1 class="mui-title">预警提醒</h1>
		</header>
		<div class="mui-content" id="content">
			<div class="xbzx-table-content">
				<div class="mui-scroll-wrapper">
					<!--这里放置真实显示的DOM内容-->
					<!--<div class="xbzx-table-cell" v-for="item in dataObj.list" @click="openDetail(item.id,item.type,'scanResult.html',$event)" v-bind:title="item.isnew">-->
					<div class="xbzx-table-cell" v-for="item in dataObj.list">
						<span class="xbzx-cell-5 mui-ellipsis warmName"><!--<i :class="[(item.isnew!='1')?'new':'','status']"></i>--><i class="warm_type">{{ item.type}}</i>{{ item.content }}</span>
						<span :class="[item.status=='已过期' ? 'over' : 'later', 'xbzx-cell-3','mui-ellipsis']">{{ item.status }}</span>

						<span class="xbzx-cell-2 mui-ellipsis time">{{ item.endtime }}</span>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script src="js/lib/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/mui.min.js"></script>
	<script src="js/common/server_commonFun.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/common/rutour.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/lib/vue.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var vm = new Vue({
			el: '#content',
			data: {
				dataObj: {},
				page: 0,
				token: ''
			},
			mounted: function() {
				this.init();
			},
			methods: {
				init: function() {
					mui.plusReady(function() {
						var currentView = plus.webview.currentWebview(); // 获取 当前webview
						currentView.show('slide-in-right', 300); // 显示当前webview (方式,时间)
						plus.nativeUI.closeWaiting(); // 关闭系统 loading 等待框
					})

					var $top = $('.xbzx-table-content').offset().top,
						$rem = $('.mui-content').attr('data-rem'),
						$content = $(document).height() - $top - (0.24 * $rem);
					console.log($top)
					console.log($content)
					$('.mui-scroll-wrapper').css({
						"top": $top,
						"left": 0.6 * $rem,
						"right": 0.6 * $rem,
						"width": "auto"
					})
					mui.init({
						pullRefresh: {
							container: ".mui-content", //下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
							down: {
								style: 'circle', //必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
								color: '#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
								height: '50px', //可选,默认50px.下拉刷新控件的高度,
								range: '100px', //可选 默认100px,控件可下拉拖拽的范围
								offset: '45px', //可选 默认0px,下拉刷新控件的起始位置
								auto: true, //可选,默认false.首次加载自动上拉刷新一次
								callback: pulldownRefresh //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据							}
							},
							up: {
								height: 10, //可选.默认50.触发上拉加载拖动距离
								auto: false, //可选,默认false.自动上拉加载一次
								contentrefresh: "正在加载...", //可选，正在加载状态时，上拉加载控件上显示的标题内容
								contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
								callback: pullupRefresh //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
							}
						}
					});

					function pullupRefresh() {
						mui.plusReady(function() {
							//							token = plus.storage.getItem('token');
							mui.ajax(rutour.warn.lists + vm.token, {
								dataType: 'json',
								type: 'get',
								data: {
									pageSize: 10,
									page: vm.page
								},
								success: function(data) {
									if(data.code == 200) {
										console.log(data);
										vm.dataObj.list = vm.dataObj.list.concat(data.data.remindList.list);
										vm.page = data.data.remindList.pageNumber + 1;
									} else {
										mui.toast(data.msg)
									};
									console.log(data.data.remindList.lastPage)
									mui('.mui-content').pullRefresh().endPullup(data.data.remindList.lastPage); //参数为true代表没有更多数据了。
								}
							})
						});
					}

					/**
					 * 下拉刷新具体业务实现
					 */
					//pulldownRefresh();

					function pulldownRefresh() {
						mui.plusReady(function() {
							vm.token = plus.storage.getItem('token');
							mui.ajax(rutour.warn.lists + vm.token, {
								dataType: 'json',
								type: 'get',
								data: {
									pageSize: 10
								},
								success: function(data) {
									console.log(data);
									if(data.code == 200) {
										vm.dataObj = data.data.remindList;
										vm.page = data.data.remindList.pageNumber + 1;
									} else {
										mui.toast(data.msg)
									};
									mui('.mui-content').pullRefresh().endPulldown();
									mui('.mui-content').pullRefresh().refresh(data.data.firstPage); // 重置上拉加载 (没有更多数据后禁用了上拉加载   在下拉重新拉去数据的时候重置上拉加载)
								}
							})
						});
					}
				},
				openDetail: function(id, type, urlName,event) { // -删除需求
					var $contentW = localStorage.getItem('$contentW'),
						$menuLeftW = localStorage.getItem('$menuLeftW');
					var dom = $(event.currentTarget); // 当前点击的 dom

					if (dom.attr('title') != 1) { // 查看过的不在修改
						mui.ajax(rutour.clickUpdate + vm.token, {
							type: 'get',
							data: {
								id: id
							},
							success:function (data) {
								dom.find('i.status').removeClass('new');
							}
						})
					}

					if(type == '行政许可') {
						var nwaiting = plus.nativeUI.showWaiting();
						webviewShow = plus.webview.create(urlName, urlName, {
							left: $menuLeftW,
							width: $contentW,
						}, {
							rid: id
						});
					} else {
						return false;
					}
				}
			}
		})
	</script>

</html>